home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-02 / wgt_tp1.zip / WGT07.PAS < prev   
Pascal/Delphi Source File  |  1992-07-05  |  3KB  |  88 lines

  1. {**************************************************************************
  2.                           WordUp Graphics Toolkit
  3.                                 Demo File
  4.  
  5.  This program initializes a second screen in memory and loads a PCX image
  6.  onto that screen. When the mouse is moved, a 20*20 section of the second
  7.  screen is copied onto the first. The left button causes the entire second
  8.  screen to be dissolved onto the visual screen.
  9.  **************************************************************************}
  10.  
  11. USES Graph,WGT,CRT;
  12. CONST cursor : mousemap = (0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
  13.                            $07C0,$0440,$07C0,$0100,$0100,$0100,$0100,$FFFF,
  14.                            $0100,$0100,$0100,$0280,$0440,$0820,$1010,$2008);
  15.                            {This bitmap is of a stick figure. No Mask.}
  16.  
  17. VAR
  18.    x, y, button, oldx, oldy, grDriver, grMode : INTEGER;
  19.    second : SCREENPTR;
  20.    installed : BOOLEAN;
  21.    p : PALETTE;                 { This is a type specific to WGT }
  22.  
  23. BEGIN
  24.      CLRSCR;
  25.      WRITELN('Press right mouse button to end the program.');
  26.      DELAY(6000);
  27.  
  28.      { Initialize graphics (see demo file #1) }
  29.      grDriver := INSTALLUSERDRIVER('VGA256',NIL);
  30.      grMode := 0;
  31.      INITGRAPH(grDriver,grMode,'c:\tp\bgi');
  32.  
  33.      _ClearDevice(0);
  34.  
  35.      Load_Palette('c:\tp\wgt\mickey.pal',p);   { Load palette and set it }
  36.      Set_Palette_Block(0,255,p);
  37.  
  38.      second:=NIL;                     { Initialize variable }
  39.      Init_Screen(second);             { Reserve memory for screen 2 }
  40.      currentscreen:=second;           { Set  operations to screen 2 }
  41.      LoadPCX('c:\tp\wgt\mickey.pcx'); { Load PCX onto current page  }
  42.      currentscreen:=basescreen;       { Set  operations to visual page }
  43.  
  44.  
  45.      mouse_init(installed, button);          { Initialize mouse }
  46.      mouse_cursor(8,8,cursor);               { New cursor shape }
  47.      mouse_on;                               { Display cursor   }
  48.      oldx:=-1;            { Set previous coordinates so display is updated }
  49.      oldy:=-1;
  50.  
  51.      REPEAT
  52.            mouse(x,y,button);     { Read in x,y and button status }
  53.  
  54.            IF ( x <> oldx ) OR ( y <> oldy ) THEN BEGIN     { If moved }
  55.  
  56.               mouse_off;                { Disable cursor while updating }
  57.  
  58.               Copy_Screen(x,y,x+19,y+19,second,x,y,basescreen);
  59.               { Copies a 20*20 section of page 2 to visual screen }
  60.  
  61.               oldx:=x;                  { Set new coordinates }
  62.               oldy:=y;
  63.               mouse_on;                 { Display cursor again }
  64.            END;
  65.  
  66.            { Now check to see if the left button is pressed }
  67.  
  68.            IF ( button=1 ) THEN BEGIN
  69.  
  70.               mouse_off;                { Disable cursor }
  71.  
  72.               Patches(7,second,0);      { Dissolve page 2 with highest res }
  73.                                         { 0 is delay between each copy     }
  74.  
  75.               DELAY(1000);              { Wait for a bit and clear screen  }
  76.               _cleardevice(0);
  77.  
  78.               mouse_on;
  79.            END;
  80.  
  81.      UNTIL button=2;       { Right hand button ends the program }
  82.  
  83.      Remove_Screen(second);
  84.  
  85.      { Now close the graphics system }
  86.  
  87.      CLOSEGRAPH;
  88. END.